import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe, VersioningType } from '@nestjs/common';
import { HelloFilter } from './hello.filter';
import { MyLogger } from './MyLogger';
import { WINSTON_LOGGER_TOKEN } from './winston/winston.module';

async function bootstrap() {
    const app = await NestFactory.create(AppModule);
    console.log("启动服务 http://localhost:3000");


    // 全局pipes 开启才能对参数进行校验
    app.useGlobalPipes(new ValidationPipe());
    // 全局filter
    // app.useGlobalFilters( new HelloFilter())

    // 开启接口版本功能
    app.enableVersioning({
        type:VersioningType.HEADER,
        header:"version"
    })

    // 引入logger  未封装的动态模块
    // app.useLogger(new MyLogger())
    // 引入logger 封装动态模块
    app.useLogger(app.get(WINSTON_LOGGER_TOKEN));

    await app.listen(3000);
}
bootstrap();
